package com.psdi.manager;

import com.psdi.element.ElementObject;
import com.psdi.element.Tag;

import java.util.*;

/**
 * 元素管理器类
 * 用于管理游戏中的各种元素
 */
public class ElementManager {

    private static ElementManager INSTANCE = null;
    private final Map<Tag, List<ElementObject>> gameElements = new HashMap<>();


    private ElementManager() {
        for (Tag tag : Tag.values()) {
            gameElements.put(tag, new ArrayList<>());
        }
    }

    public static synchronized ElementManager getINSTANCE() {
        if (INSTANCE == null) {
            INSTANCE = new ElementManager();
        }
        return INSTANCE;
    }

    public Map<Tag, List<ElementObject>> getGameElements() {
        return gameElements;
    }

    public void addElement(ElementObject elementObject) {
        gameElements.get(elementObject.tag).add(elementObject);
    }

}
